<?php

namespace app\api\model;

use think\Model;

class ResidentialQuarters extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'ty_residential_quarters';

    //指定主见
    protected $pk = 'rq_id';

    //只读字段
    //protected $readonly = ['name','email'];

    //自动写入时间戳
    //protected $autoWriteTimestamp = true;

    //自动写入日期
    //protected $autoWriteTimestamp = 'datetime';

    // 设置返回数据集的对象名
    protected $resultSetType = 'collection';

    public static function getIdList($where)
    {
        if(!empty($where)){
            $list = self::where([$where])->field('rq_id')->select();

        }else{
            $list = self::field('rq_id')->select();
        }
        foreach ($list as $k => $v){
            $data[] = $v['rq_id'];
        }
        return  $data;
    }
    public static function getRqName($id)
    {
        $res = self::where(['rq_id' => $id])->find();
        return $res ? $res['rq_name'] : '';
    }
}
